using System;
using System.Collections.Generic;
using System.Text;
using WindowsLive.Writer.Api;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace InsertTranslation
{
    [WriterPlugin("2c588bca-17f5-4d52-8f4c-c64e7eeceafb", "Insert Google Translation",
        Description = "Insert a translation from Google Translate",
        HasEditableOptions = false,
        Name = "Insert Translation",
        PublisherUrl = "http://scottisafooldev.spaces.live.com",
        ImagePath = "google.gif")]
    [InsertableContentSource("Translation")]

    public class GoogleTranslate : ContentSource
    {
        // If you change the name after class, please change it here too
        public GoogleTranslate()
        { }

        public override DialogResult CreateContent(IWin32Window dialogOwner, ref string newContent)
        {
            newContent = Regex.Replace(newContent, @"<(.|\n)*?>", string.Empty);

            using (frmMain main = new frmMain(newContent))
            {
                DialogResult result = main.ShowDialog();
                if (result == DialogResult.OK)
                {
                    newContent = main.transresult;
                }
                return result;
            }
        }
    }
}
